package model.expression.command;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

import state.TabState;
import state.TurtleState;

import model.expression.AbstractExpression;
import model.parser.ParserException;

public abstract class AbstractCommandExpression extends AbstractExpression {

	public List<AbstractExpression> children;
	TabState tabSt;
	public AbstractCommandExpression(List<AbstractExpression> children) {
		this.children = children;
	}

	/*history method, prepare to delete	
	public AbstractCommandExpression(TurtleState ts){
		this.children=new ArrayList<AbstractExpression>();
		this.ts=ts;
	}
	*/
	
	public AbstractCommandExpression(TabState ts){
		this.children=new ArrayList<AbstractExpression>();
		this.tabSt=ts;
	}

	
	public  void addChildrenFrom(Stack<AbstractExpression> out){
		for(int i=0;i<this.getExpNumChildren();i++){
			if(out.empty()){
				throw ParserException.BAD_ARGUMENTS;
			}
			this.children.add(out.pop());
		}
	}

	protected abstract int getExpNumChildren();

	/*history method, prepare to delete
	public void newCoords(int newX, int newY) {
		ts.oldX=ts.x;
		ts.oldY=ts.y;
		ts.setx(newX);
		ts.sety(newY);
		ts.notifyObservers();		
	}
	*/

	public void newCoords(int newX, int newY, TurtleState st) {
		st.setx(newX);
		st.sety(newY);
		st.notifyObservers();		
	}
}
